package a29_CommenAlgorithm.Search;

/**
 * @Author quan
 * @Description 基础查找：判断某个元素是否存在
 * {131,127,147,81,103,23,7,79}
 * @Date 2023/2/20 23:39
 */
/**核心：从0索引开始依次查找，又叫做顺序查找
 */
public class BasicSearch1 {
    public static void main(String[] args) {
        int[] arr = {131,127,147,81,103,23,7,79};
        int number = 81;
        System.out.println(basicSearch(arr,number));
    }
    //查找方法
    public static boolean basicSearch(int[] arr, int number){
        for (int i = 0; i < arr.length; i++) {
            if(arr[i] == number){
                return true;
//                return i;//返回所查找元素的索引
            }
        }
        return false;
//        return -1;//没有该元素
    }
}
